package com.bw.coupon.controller;/**
 * @Author：尚志豪
 * @Package：com.bw.coupon.controller
 * @Project：doudi-group-practical_training-02
 * @name：PlatformController
 * @Date：2025/1/16 17:04
 */

import com.bw.common.core.domain.Result;
import com.bw.common.core.web.controller.BaseController;
import com.bw.coupon.domain.req.AuditReq;
import com.bw.coupon.domain.req.StatusReq;
import com.bw.coupon.domain.res.TDiscountCouponRes;
import com.bw.coupon.service.IPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;



/**
 * @program: doudi-group-practical_training-02
 * @description: 平台控制层
 * @author: CuiFu Bo
 * @create: 2025-01-16 17:04
 **/
@RestController
@RequestMapping("/platform")
public class PlatformController extends BaseController
{

    @Autowired
    private IPlatformService iPlatformService;

    /**
     * B端 平台 查询未审核的优惠卷分页列表
     */
    @PostMapping("/queryTheListOfUnauditedDiscountPages")
    public Result queryTheListOfUnauditedDiscountPages(@RequestBody StatusReq statusReq)
    {
        startPage();
        Long status = statusReq.getStatus();
        List<TDiscountCouponRes> list = iPlatformService.queryTheListOfUnauditedDiscountPages(status);
        return getDataTable(list);
    }
    /**
     * B端 平台 通过优惠劵id给优惠劵审核 同意
     */
    @PostMapping("/passCouponIdToCouponForReview/{id}")
    public Result passCouponIdToCouponForReview(@PathVariable Long id)
    {
        AuditReq auditReq = new AuditReq();
        auditReq.setStatus(1L);
        Long status = auditReq.getStatus();
        iPlatformService.passCouponIdToCouponForReview(id,status);
        return Result.success("优惠劵已审核");
    }
    /**
     * B端 平台 通过优惠劵id给优惠劵审核 不同意
     */
    @PostMapping("/passCouponIdToCouponForReviewON/{id}")
    public Result passCouponIdToCouponForReviewON(@PathVariable Long id)
    {
        AuditReq auditReq = new AuditReq();
        auditReq.setStatus(4L);
        Long status = auditReq.getStatus();
        iPlatformService.passCouponIdToCouponForReview(id,status);
        return Result.success("优惠劵已审核");
    }


}
